/*
 * Copyright 2011 Mark Davidson.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.dctmcommons.impl;

import org.dctmcommons.ICoreObjectInfo;

/**
 * Default implementation of {@link ICoreObjectInfo<}.
 * @author Mark Davidson
 */
public class CoreObjectInfo implements ICoreObjectInfo {

	/** The object type. */
	private String objectType = null;
	
	/** The object name. */
	private String objectName = null;
	
	/** The object id. */
	private String objectId = null;
	
	/** The folder path. */
	private String folderPath = null;
	
	/** The object path. */
	private String objectPath = null;
	
	/** The ACL name. */
	private String aclName = null;
	
	/** The content size. */
	private int contentSize = 0;
	
	/** The content type. */
	private String contentType = null;
	
	/** The link count. */
	private int linkCount = 0;
	
	/** Whether the object is a virtual document. */
	private boolean virtualDoc = false;
	
	/**
	 * The default constructor.
	 */
	private CoreObjectInfo() {}
	
	/**
	 * Factory method.
	 * @return An instance of {@link CoreObjectInfo}
	 */
	public static CoreObjectInfo getInstance() {
		return new CoreObjectInfo();
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getObjectType()
	 */
	@Override
	public String getObjectType() {
		return objectType;
	}
	
	/**
	 * Sets the object type.
	 * @param objectType The object type
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setObjectType(final String objectType) {
		this.objectType = objectType;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getObjectName()
	 */
	@Override
	public String getObjectName() {
		return objectName;
	}
	
	/**
	 * Sets the object name.
	 * @param objectName The object name
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setObjectName(final String objectName) {
		this.objectName = objectName;
		return this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getObjectId()
	 */
	@Override
	public String getObjectId() {
		return objectId;
	}

	/**
	 * Sets the object id.
	 * @param objectId The object id
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setObjectId(final String objectId) {
		this.objectId = objectId;
		return this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getFolderPath()
	 */
	@Override
	public String getFolderPath() {
		return folderPath;
	}

	/**
	 * Sets the folder path.
	 * @param folderPath The folder path
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setFolderPath(final String folderPath) {
		this.folderPath = folderPath;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getObjectPath()
	 */
	@Override
	public String getObjectPath() {
		return objectPath;
	}

	/**
	 * Sets the object path.
	 * @param objectPath The object path
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setObjectPath(final String objectPath) {
		this.objectPath = objectPath;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getAclName()
	 */
	@Override
	public String getAclName() {
		return aclName;
	}

	/**
	 * Sets the ACL name.
	 * @param aclName The ACL name
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setAclName(final String aclName) {
		this.aclName = aclName;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getContentSize()
	 */
	public int getContentSize() {
		return contentSize;
	}
	
	/**
	 * Sets the content size.
	 * @param contentSize The content size
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setContentSize(final int contentSize) {
		this.contentSize = contentSize;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getContentType()
	 */
	public String getContentType() {
		return contentType;
	}
	
	/**
	 * Sets the content type.
	 * @param contentType The content type
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setContentType(final String contentType) {
		this.contentType = contentType;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#getLinkCount()
	 */
	public int getLinkCount() {
		return linkCount;
	}
	
	/**
	 * Sets the link count.
	 * @param linkCount The link count
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setLinkCount(final int linkCount) {
		this.linkCount = linkCount;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.dctmcommons.ICoreObjectInfo#isVirtualDoc()
	 */
	public boolean isVirtualDoc() {
		return virtualDoc;
	}
	
	/**
	 * Specifies whether the object is a virtual document.
	 * @param virtualDoc Whether the object is a virtual document
	 * @return This {@link CoreObjectInfo} instance.
	 */
	public CoreObjectInfo setVirtualDocument(final boolean virtualDoc) {
		this.virtualDoc = virtualDoc;
		return this;
	}
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		
		sb.append("name = " + getObjectName() + ", ");
		sb.append("type = " + getObjectType() + ", ");
		sb.append("id = " + getObjectId() + ", ");
		sb.append("acl = " + getAclName() + ", ");
		sb.append("content = " + getContentType() + ", ");
		sb.append("path = " + getObjectPath() + ", ");
		sb.append("parent = " + getFolderPath() + ", ");
		sb.append("children = " + getLinkCount() + ", ");
		sb.delete(sb.length()  -3, sb.length() - 1);

		return sb.toString();
	}
}
